﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using System.Windows.Forms;

namespace ProgNetComponentsDx.Shortcut.Design
{
    public class ShortcutTypeConverter : ProgNetComponents.Design.TypeConverters.CollectionItemTypeConverter<Shortcut>
    {
        protected override ConstructorInfo GetConstructor(Shortcut item)
        {

            if (item.DefaultShortcut == Keys.None)
            {
                return item.GetType().GetConstructor(new Type[]{
                        typeof(string)});
            }
            else
            {
                return item.GetType().GetConstructor(new Type[]{
                        typeof(string),
                        typeof(Keys)});
            }
        }

        protected override object[] GetConstructorParamters(Shortcut item)
        {
            if (item.DefaultShortcut == Keys.None)
            {
                return new object[] { item.Name };
            }
            else
            {
                return new object[]{item.Name,
                        item.DefaultShortcut};
            }
        }
    }
}
